<template>
    <div class="start-menu">
        <div class="title">开始</div>
        <div class="options">
            <div class="user-info">
                <i class="iconfont icon-yonghu-yuan"></i>
                <span v-text="userStore.get.username"></span>
            </div>
            <div class="option" @click="openAddAppWindow">
                <i class="iconfont icon-icon_yingyongguanli"></i>
                <span>添加应用</span>
            </div>
            <div class="option" @click="logout">
                <i class="iconfont icon-guanji"></i>
                <span>退出登陆</span>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { useWindowStore } from '@/store/window';
import { useUserStore } from '@/store/user';
import { useRouter } from 'vue-router';

// 创建store对象
const windowStore = useWindowStore();
const userStore = useUserStore();

// 创建路由对象
const router = useRouter();

// 打开添加应用窗口
const openAddAppWindow = () => {
    windowStore.push({
        id: new Date().getTime() + '',
        icon: '/add-app.png',
        title: '添加应用',
        url: 'add-app',
    });
};

// 退出登录
const logout = () => {
    userStore.clear();
    router.push('/login');
};
</script>

<style scoped lang="less">
.start-menu {
    height: 500px;
    width: 250px;
    background-color: rgb(30, 40, 50);
    box-sizing: border-box;
    padding: 15px;
    position: relative;
    color: @dps-color-light-gray;

    .title {
        font-size: @dps-font-size-lg;
    }

    .options {
        width: 100%;
        position: absolute;
        bottom: 0;
        left: 0;
        font-size: @dps-font-size-base;

        .option,
        .user-info {
            height: 50px;
            width: 100%;
            transition: all 100ms;
            box-sizing: border-box;
            padding: 0 15px;
            display: flex;
            align-items: center;
            justify-content: flex-start;

            i {
                font-size: 20px;
                margin-right: 15px;
            }
        }

        .option:hover {
            background-color: @dps-color-light-gray-15;
        }
    }

    .start-menu {
        position: absolute;
        bottom: 40px;
        left: 0;
        transition: all 300ms;
        transform: scaleY(0);
        transform-origin: 0 100%;
    }

    .start-menu-slide {
        transform: scaleY(1);
    }
}
</style>
